# coding: utf-8

import pandas as pd

df = pd.read_excel(r'F:\Work\Python\Pandas\study-pandas\file\datas\student.xlsx', skiprows=2)
#print(df)

# 1.null/notnull
# print(df['分数'].isnull())
# print(df['分数'].notnull())
# print(df.loc[df['分数'].notnull(), :])

# 2.dropna
# axis：0--行, 1--列
# how: any任意, all所有
# inplace: Ture--直接修改dataframe, False--返回新的df
# df.dropna(axis='columns', how='all', inplace=True)
# print(df)
# df.dropna(axis='index', how='all', inplace=True)
# print(df)

# 3.fillna
# 用法一
# print(df.fillna({'分数': 0}))
# 用法二
# df.loc[:, '分数'] = df['分数'].fillna(0)
# print(df)

# 4.ffill 用前面的值填充
df.loc[:, '姓名'] = df['姓名'].ffill()
print(df)

# 5.写入excel
df.to_excel(r'F:\Work\Python\Pandas\study-pandas\file\datas\student_new.xlsx', index=False)
